package org.nidy.erp.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

@Slf4j
//@Component
//@Aspect
//@Order(1)// 当同一切点存在多个通知时，设置切面优先级，数字越小优先级越高
public class DemoAspect {
    //切入点表达式
    @Pointcut(value = "execution(* org.nidy.erp.service.*.*(..))")
    private void pointCut() {}
    //前置通知
    @Before(value = "pointCut()")
    public void before() {
        log.info("before");
    }
    //环绕通知
    @Around(value = "pointCut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        Object result = joinPoint.proceed();
        log.info("around");
        return result;
    }
    //后置通知
    @After(value = "pointCut()")
    public void after() {
        log.info("after");
    }
    //异常通知
    @AfterThrowing(value = "pointCut()")
    public void afterThrowing() {
        log.info("afterThrowing");
    }
    //后置返回通知
    @AfterReturning(value = "pointCut()")
    public void afterReturning() {
        log.info("afterReturning");
    }
}
